package com.blog.backend.gateWayController;

import com.blog.backend.annotation.LoginAnno;
import com.blog.backend.domain.BlogSummary;
import com.blog.backend.resp.BlogAlbumResp;
import com.blog.backend.resp.BlogAssessResp;
import com.blog.backend.resp.IndexArticleResp;
import com.blog.backend.resp.SummaryResp;
import com.blog.backend.service.BlogIndexManagerService;
import com.blog.backend.utils.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/doorIndex")
public class DoorIndexController {

    @Resource
    private BlogIndexManagerService blogIndexManagerService;

    @GetMapping("/getIndexAlbums")
    @ApiOperation("查询首页相册列表")
    public Result<List<BlogAlbumResp>> getIndexAlbums(){
        List<BlogAlbumResp> resps=blogIndexManagerService.getIndexAlbums();
        return Result.success(resps);
    }

    @GetMapping("/getIndexSummary")
    @ApiOperation("查看年度总结")
    public Result<BlogSummary> getIndexSummary(){
        BlogSummary summary= blogIndexManagerService.getIndexSummary();
        return Result.success(summary);
    }

    @GetMapping("/selectIndexArticle")
    @ApiOperation("最热门的文章列表")
    public Result<List<IndexArticleResp>> selectIndexArticle(){
        List<IndexArticleResp> list=blogIndexManagerService.selectHotArticle(3);
        return Result.success(list);
    }

    @GetMapping("/getNewAssessList")
    @ApiOperation("最新点评")
    public Result<List<BlogAssessResp>> getNewAssessList(){
        List<BlogAssessResp> list = blogIndexManagerService.getNewAssessList();
        return Result.success(list);
    }

    @GetMapping("/getNewArticleList")
    @ApiOperation("查看每个版本最新的三篇文章")
    public Result<List<IndexArticleResp>> getNewArticleList(){
        List<IndexArticleResp> list=blogIndexManagerService.getNewArticleList(3);
        return Result.success(list);
    }

    @GetMapping("/getSummaryDetail")
    public Result<SummaryResp> getSummaryDetail(@RequestParam String summaryId){
        SummaryResp resp=blogIndexManagerService.getSummaryDetail(summaryId);
        return Result.success(resp);
    }

    @GetMapping("/getPhotosByType")
    public Result<BlogAlbumResp> getPhotosByType(@RequestParam String type){
        BlogAlbumResp resp=blogIndexManagerService.getPhotosByType(type);
        return Result.success(resp);
    }

    @GetMapping("/getNewTechnology")
    public Result<IndexArticleResp> getNewTechnology(){
        IndexArticleResp resp=blogIndexManagerService.getNewTechnology();
        return Result.success(resp);
    }
}
